#!/bin/bash

# Staging环境服务控制脚本
# 使用方法: ./staging-control.sh [start|stop|restart|status|logs]

SERVER_IP="47.237.10.129"
SERVER_USER="root"

case "$1" in
    start)
        echo "🚀 启动Staging服务..."
        ssh $SERVER_USER@$SERVER_IP "cd /opt/cumbull/backend && pm2 start cumrbull-staging"
        ;;
    stop)
        echo "🛑 停止Staging服务..."
        ssh $SERVER_USER@$SERVER_IP "pm2 stop cumrbull-staging"
        ;;
    restart)
        echo "🔄 重启Staging服务..."
        ssh $SERVER_USER@$SERVER_IP "pm2 restart cumrbull-staging"
        ;;
    status)
        echo "📊 Staging服务状态:"
        ssh $SERVER_USER@$SERVER_IP "pm2 status cumrbull-staging"
        ;;
    logs)
        echo "📝 Staging服务日志:"
        ssh $SERVER_USER@$SERVER_IP "pm2 logs cumrbull-staging --lines 50"
        ;;
    *)
        echo "使用方法: $0 {start|stop|restart|status|logs}"
        exit 1
        ;;
esac
